//codes.js   
system = require('system')
address = system.args[1];// 获得命令行第二个参数 接下来会用到
// console.log('Loading a web page');
var page = require('webpage').create();
var url = address;
// console.log(url);
page.open(url, function(status) {
	// Page is loaded!
	if (status !== 'success') {
		console.log('Unable to post!');
	} else {
		page.evaluate(function() {
			// 此函数在目标页面执行的，上下文环境非本phantomjs，所以不能用到这个js中其他变量
			window.scrollTo(0, 100000);// 滚动到底部

			window.setTimeout(function() {
				console.log('begin score') ;
				var plist = document.querySelectorAll("a");
				var len = plist.length;
				console.log(len)
				while (len) {
					len--;
					var el = plist[len];
					el.style.border = "1px solid red";
				}
			}, 5000);
		});

		window.setTimeout(function() {
			console.log(page.content);
			phantom.exit();
		}, 5000+500);
	}
});
